package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.mathematics.vector.vec2.Vector2
import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.Vector4

infix fun<T:Number> Vector2<T,*>.distanceTo(other: Vector2<T,*>) = (this  - other).length
infix fun<T:Number> Vector2<T,*>.distanceTo(other: Vector3<T,*>) = (other - this).length
infix fun<T:Number> Vector2<T,*>.distanceTo(other: Vector4<T,*>) = (other - this).length

infix fun<T:Number> Vector3<T,*>.distanceTo(other: Vector2<T,*>) = (this - other).length
infix fun<T:Number> Vector3<T,*>.distanceTo(other: Vector3<T,*>) = (this - other).length
infix fun<T:Number> Vector3<T,*>.distanceTo(other: Vector4<T,*>) = (other - this).length

infix fun<T:Number> Vector4<T,*>.distanceTo(other: Vector2<T,*>) = (this - other ).length
infix fun<T:Number> Vector4<T,*>.distanceTo(other: Vector3<T,*>) = (this - other ).length
infix fun<T:Number> Vector4<T,*>.distanceTo(other: Vector4<T,*>) = (this - other ).length


infix fun<T:Number> Vector2<T,*>.squaredDistanceTo(other: Vector2<T,*>) = (this  - other).squaredLength
infix fun<T:Number> Vector2<T,*>.squaredDistanceTo(other: Vector3<T,*>) = (other - this ).squaredLength
infix fun<T:Number> Vector2<T,*>.squaredDistanceTo(other: Vector4<T,*>) = (other - this ).squaredLength

infix fun<T:Number> Vector3<T,*>.squaredDistanceTo(other: Vector2<T,*>) = (this - other).squaredLength
infix fun<T:Number> Vector3<T,*>.squaredDistanceTo(other: Vector3<T,*>) = (this - other).squaredLength
infix fun<T:Number> Vector3<T,*>.squaredDistanceTo(other: Vector4<T,*>) = (other - this).squaredLength

infix fun<T:Number> Vector4<T,*>.squaredDistanceTo(other: Vector2<T,*>) = (this - other ).squaredLength
infix fun<T:Number> Vector4<T,*>.squaredDistanceTo(other: Vector3<T,*>) = (this - other ).squaredLength
infix fun<T:Number> Vector4<T,*>.squaredDistanceTo(other: Vector4<T,*>) = (this - other ).squaredLength
